package com.qingke.easyjava.jdbc.app;

public class Singleton {

	/*饿汉模式-最常用
		private static BeSuperApplication instance;
		
		private BeSuperApplication() {
			
		}
		
		public static BeSuperApplication getInstance() {
			if(instance == null ){
				synchronized(instance) {
				instance = new BeSuperApplication();
				}
			}
			return instance;
		}*/
	//  懒汉模式。第二、三种要new
	private static Singleton instance = new Singleton();
	// 不需要同步关键字，也不要判断，只是读的一个过程

	private Singleton() {
	}

	public static synchronized Singleton getInstance() {
		return instance;
	}
	/*登记模式-第三种
	private static Singleton instance = new Singleton();
	
	private Singleton() {
	}
	
	private static Map<String, Singleton> map = new HashMap<>();
	第三种要传入参数
	public static synchronized Singleton getInstance(String identifier) {
		
		Singleton instance = map.get(identifier);
		
		if (instance == null) {
			instance = new Singleton();
			map.put(identifier, instance);
		}
		
		return instance;
	}
	
	*/

}
